<?php
if (!empty ($this->arrDetail) && !empty($this->arrDetail['hotalbum'])) {
    $arrAlbumResult = $this->arrDetail['hotalbum'];    
?>
    <div id="box_hot_images_news" class="w980 left">
        <div class="content_box_images_news">
            <div class="v5-carousel enable-carousel" options="speed=700&auto=1000">
                <div class="big_slide">
                    <div class="carousel-hero-holder">
                        <div class="carousel-hero-rail">
                            <?php
                            foreach ($arrAlbumResult as $album)
                            {                                
                            ?>
                                <div class="carousel-hero-item hero-standard" type="standard">
                                    <a href="<?php echo $this->Articleurl($album, 1, 1);?>" title="<?php echo $album['title']; ?>">
                                        <img width="634" height="480" title="<?php echo $album['title']; ?>" alt="<?php echo $album['title']; ?>" class="hero-img" src="<?php echo $this->Imageurl($album['thumbnail_url'], $this->imagesize['size7']); ?>" load="<?php echo $this->Imageurl($album['thumbnail_url'], $this->imagesize['size7']); ?>" onerror="this.src='<?php echo $this->config['photo']. '/notfound_204x152.jpg' ?>'"/>
                                    </a>
                                    <h3 class=""><?php echo $album['title']; ?></h3>
                                </div>
                            <?php 
                            } ?>
                        </div>
                        <!--carousel-hero-rail-->
                    </div>
                </div>
                <!--carousel-hero-holder-->
                <div class="carousel-list-holder">
                    <ul class="carousel-list-rail">
                         <?php
                        foreach ($arrAlbumResult as $album)
                        {
                        ?>
                        <li class="carousel-list-item carousel-list-t1 ">
                            <a class="carousel-list-link" href="javascript:;" title="<?php echo $album['title']; ?>">
                                <img src="<?php echo $this->Imageurl($album['thumbnail_url'], $this->imagesize['size3']); ?>" width="290" height="217" onerror="this.src='<?php echo $this->config['photo']. '/notfound_204x152.jpg' ?>'"/>
                                <span class="light"><?php echo $album['title']; ?></span>
                            </a>
                        </li>
                        
                        <?php
                        }
                        ?>
                    </ul>
                </div>
                <!--carousel-list-holder-->
            </div>
            <div class="clear">&nbsp;</div>
        </div>
    </div>
<?php
}
?>
<?php $excluse = (isset($this->excluse) ) ? $this->excluse : ""; ?>
<input type="hidden" name="excluse" id="excluse" value='<?php echo $excluse; ?>' />
<!-- InstanceEndEditable -->
<script language="javascript" type="text/javascript" src="<?php echo $this->config['euro2012']['js']; ?>/lib/lib.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $this->config['euro2012']['js']; ?>/slides.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $this->config['euro2012']['js']; ?>/lib/jquery.min.js.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $this->config['euro2012']['js']; ?>/common.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $this->config['euro2012']['js']; ?>/slides.min.jquery.js"></script>

<script language="javascript" type="text/javascript">
     $(document).ready(function() {
        $('.show_popup').live('click', function showPopup(){
            $('.main_ct_popup').fadeIn(0);
            var ctheight = $(window).height();
            var ctwidth = $(window).width();
            var ctpopupwidth = $('#gallery').width();
            var ctpopupheight = $('#gallery').height();

            /* Get albumId */
            var albumId = $(this).attr('aid');
            var albumName = $(this).attr('albumName');
            var url_loading = IMAGES_URL+'/loading.gif';
            /* Get album detail */

            $.ajax({
                type:'GET',
                url: '<?php echo BASE_URL ?>/block/getlistphoto',
                data:({
                    albumId:albumId,
                    albumName:albumName
                }),
                dataType:'html',
                beforeSend: function(){
                    $('#thumb-list').hide();
                    $('#ad-image div.ad-image').hide();
                    $('div.not-found').remove();
                    $('#ad-image').append('<img class="ad-loader" src="'+url_loading+'" style="border: medium none; display: block;">');
                },
                success:function(response){
                    if(response != ''){
                        $('#thumb-list').html(response).fadeIn('fast', function(){
                            var galleries = $('#gallery').adGallery();

                            $('#switch-effect').change(function() {
                                galleries[0].settings.effect = $(this).val();
                                return false;
                            });

                            $('#toggle-slideshow').click(function() {
                                galleries[0].slideshow.toggle();
                                return false;
                            });

                            $('#toggle-description').click(function() {
                                if(!galleries[0].settings.description_wrapper) {
                                    galleries[0].settings.description_wrapper = $('#descriptions');
                                } else {
                                    galleries[0].settings.description_wrapper = false;
                                }
                                return false;
                            });
                        });
                    }
                    else
                    {
                        $('img.ad-loader').remove();
                        $('#ad-image').append('<div class="not-found" style="border: medium none; width:100%; text-align:center; padding-top:250px; display: block;">Không có hình ảnh nào trong album</div>');
                    }
                },
                error:function()
                {
                    $('img.ad-loader').remove();
                    $('#ad-image').append('<div class="not-found" style="border: medium none; width:100%; text-align:center; padding-top:250px; display: block;">Có lỗi xảy ra</div>');
                }
            });

            $('.content_pupop').css("left",(ctwidth- ctpopupwidth)/2);
            $('body').css('overflow' , 'hidden');

            $('.btn_close_popup a').click(function(){
                $('.main_ct_popup').fadeOut(0);
                $('body').css('overflow' , 'auto');
            });
        });
    });
    /* load ajax + showmore photo list*/
    var url_showmore_photo = '<?php echo BASE_URL ?>/block/showmore';
    var limit_photo = '<?php echo LIMIT_NEW_PHOTO_SITE; ?>'
    var limit_photo_more = '<?php echo LIMIT_SHOWMORE_PHOTO_SITE; ?>'
    var page_photo = 1;
    var cateid_photo = <?php echo CATE_ID_PHOTO; ?>;
    var excluse = '';
    
    function show_cate_photo(cateid){        
        page_photo = 1 ;
        cateid_photo = cateid;

        $.ajax({
            type:'GET',
            url:url_showmore_photo,
            data:({
                page:page_photo,
                cateid:cateid_photo,
                limit:limit_photo,
                excluse:excluse
            }),
            dataType:'json',
            success:function(response){
                if( response.html == ""){
                    $("#box_list_photo").html('<li><p class="txt_gray txt_11">Chuyên mục này chưa có album.</p> </li>');
                    $("#idShowmorePhoto").hide();
                }else{
                    $("#box_list_photo").html(response.html);
                    if( response.total >= limit_photo){
                        $("#idShowmorePhoto").show();
                    }
                }
                PVWidget.getViews();
            },
            beforeSend: function(){
                 $('#box_list_photo').html('<p style="padding-top: 10px; padding-left: 10px;" id="loading_video_id"> Đang tải dữ liệu...</p>');
            }
        });
    }
    function show_more_photo(){
        page_photo += 1;
        $.ajax({
            type:'GET',
            url:url_showmore_photo,
            data:({
                page:page_photo,
                cateid:cateid_photo,
                limit:limit_photo_more,
                excluse:excluse
            }),
            dataType:'json',
            success:function(response){
                $("#idLoadingPhoto").hide();
                $("#box_list_photo").append(response.html);
                if( response.total >= limit_photo){
                    $("#idShowmorePhoto").show();
                }
                /*liad widget number view*/
                PVWidget.getViews();
            },
            beforeSend: function(){
                 $("#idShowmorePhoto").hide();
                 $("#idLoadingPhoto").show();
            }
        });
    }
</script>